<template>
  <el-row class="min-h-screen bg-indigo-500">
    <el-col :span="16" class="flex items-center justify-center">
        <div>
            <div class="font-bold text-5xl text-light-50 mb-4">欢迎光临</div>
            <div class="text-gray-200 text-sm">交通运输人员就业与再就业教育培训平台</div>
        </div>
    </el-col>
    <el-col :span="8" class="bg-light-50 flex items-center justify-center flex-col">
        <h2 class="font-bold text-3xl text-gray-800 ">欢迎回来</h2>
        <div class="flex items-center justify-center my-5 text-gray-300 space-x-2">
            <span class="h-[1px] w-16 bg-gray-200"></span>
            <span>账号密码登录</span>
            <span class="h-[1px] w-16 bg-gray-200"></span>
        </div>
        <el-form :model="form" class="w-[250px]" :rules="rules" ref="formRef">
            <el-form-item label="用户名" prop="username">
                <el-input v-model="form.username" clearable />
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <el-input type="password" v-model="form.password" show-password clearable/>
            </el-form-item>
            <el-row class="flex items-center justify-center">
                <el-button type="primary" @click="login">登录</el-button>
                <el-button type="primary" @click="register">注册</el-button>
            </el-row>
        </el-form>
        <el-row class="justify-center py-5">
                <el-link  type="primary" @click="$router.push('/login')">管理员登录</el-link>
        </el-row>  
    </el-col>
  </el-row>
</template>

<script setup>
import { ref,reactive } from 'vue';
import { useRouter } from 'vue-router';
const form = reactive({
    username: '',
    password: ''
});
const rules = reactive({
    username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
    password: [{ required: true, message: '请输入密码', trigger: 'blur' },{pattern: /^.{6,16}$/, message: '请输入6-16位密码', trigger: 'blur'}]
});
const router = useRouter();
const register = () => {
    router.push('/stuRegister');
}
const formRef = ref(null);
const login = () => {
    formRef.value.validate((valid) => {
        if(valid){
            console.log(form);
        }
    })
}
</script>

<style>

</style>